<template>
  <div id="detail">
    <app-tableList v-if="listData.value.list.length>0" @changePage="getPage"
                   :data_table="listData.value"
                   :pageNum="listData.pageNum"
                   :totalCount="listData.totalCount" :pageSize="listData.pageSize"/>
    <p class="no-data" v-if="listData.value.list.length<1">暂无数据</p>
  </div>
</template>

<script>
  import TableList from '@/components/component/table_list.vue'
  import {Toast} from 'vant'
  import Api from '@/axios'

  export default {
    name: 'profits',
    data() {
      return {
        currencyType: [],
        currentId: null,
        listData: {
          totalCount: null, // 总条数
          pageNum: 1, // 当前显示页号
          pageSize: 10, // 每页显示数据条数
          value: {
            nav: [
              {name: '日期'},
              {name: 'ONEBET 持有量'},
              {name: '分红'}
            ],
            list: [],
            attr: [
              'date',
              'onebetAmount',
              'dividend'
            ]
          }
        }
      }
    },
    components: {
      'app-tableList': TableList
    },
    methods: {
      getProfitsdata() {
        let params = {
          pageSize: this.listData.pageSize,
          pageNum: this.listData.pageNum
        }
        Api.getProfits(params).then(res => {
          let result = res.data
          if (result.code === 0) {
            this.listData.totalCount = result.data.totalCount
            this.listData.value.list = result.data.data
          } else {
            Toast(result.message)
          }
        })
      },
      getPage(page) {
        this.listData.pageNum = page
        this.getProfitsdata()
      }
    },
    mounted() {
      this.getProfitsdata()
    }
  }
</script>

<style scoped>

</style>
